// #include"Com.hpp"

// extern Log log;

// int main()
// {
//     sleep(3);
//     int shmid = CreateShm();
//     log(Debug, "creat shm done, success");
    
//     sleep(5);

//     char* shmaddr = (char*)shmat(shmid, nullptr, 0);         //挂接成功
//     log(Debug, "attach shm done, success");              

//     sleep(5);
//     shmdt(shmaddr);
//     log(Debug, "attach shm done, shmaddr: ox%x", shmaddr);   //取消挂接

//     sleep(5);


//     shmctl(shmid, IPC_RMID, nullptr);
//     log(Debug, "detach shm done, shmaddr: ox%x", shmaddr);

//     sleep(5);

//     return 0;
// }


#include"Com.hpp"

extern Log log;

int main()
{
    int shmid = CreateShm();
    char* shmaddr = (char*)shmat(shmid, nullptr, 0);         //挂接成功

//ipc code

    struct shmid_ds shmds;
    while(true)
    {
        cout << "client say@ " << shmaddr << endl;   //直接访问共享内存， 将内存里面的数据打印到
        sleep(1);   
        shmctl(shmid, IPC_STAT, &shmds); //读id的快， 将数据达到最后。
        cout << "shm size: " << shmds.shm_segsz << endl;
        cout << "shm nattch: " << shmds.shm_nattch << endl;
        cout << "shm _key: " << shmds.shm_perm.__key << endl;

    }
//


    shmdt(shmaddr);
    shmctl(shmid, IPC_RMID, nullptr);

    return 0;
}